import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { OpenExcelButton, ModDataButton, OpenTwoRouter, DelDataButton } from '../Common/options'
import { v4 } from 'uuid'

export const HazardousLargeScaleProjects = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenExcelButton
                key="two"
                title="批量导入"
                OptionsEvent={OptionsEvent}
                data={{
                    save: true,
                    submit: true,
                    url: 'getHazardousLargeScaleProjectExcel',
                    pos: 'posHazardousLargeScaleProjectExcel',
                    HazardousLargeScaleProjectUuid: v4(),
                }}
            />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'HazardousLargeScaleProjects' },
            commonTableList.uuid,
            {
                dataIndex: 'eventDate',
                title: '日期',
                valueType: 'Date',
                width: 160,
                hideInSearch: true,
            },
            {
                ...commonTableList.organizationUuid,
                valueEnum: ClientData.organization,
                hideInModify: true,
                title: '施工单位',
            },

            {
                dataIndex: 'contractor',
                title: '施工单位',
                valueType: 'input',
                width: 160,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'inspectionItem',
                title: '检查项目',
                valueType: 'input',
                width: 160,
                ellipsis: true,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'hazardousLargeScaleProject',
                title: '专项施工方案',
                valueType: 'input',
                width: 160,
                ellipsis: true,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'isHazardousLargeScaleProject',
                title: '是否存在',
                valueType: 'input',
                width: 160,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'superHazardousLargeScaleProject',
                title: '专家论证',
                valueType: 'input',
                width: 160,
                ellipsis: true,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'isSuperHazardousLargeScaleProject',
                title: '是否存在',
                valueType: 'input',
                width: 160,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'specialPlanApprovalDate',
                title: '专项方案审批日期',
                valueType: 'Date',
                width: 160,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'expertDemonstrationDate',
                title: '专家论证日期',
                valueType: 'Date',
                width: 160,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'implementationCompletionDate',
                title: '实施完毕日期',
                valueType: 'Date',
                width: 160,
                ellipsis: true,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'hazardousLargeScaleProjectUuid',
                title: '申报主表的表编号',
                valueType: 'input',
                width: 160,
                ellipsis: true,
                hideInSearch: true,
                hideInModify: true,
            },
            commonTableList.BeginSecurityDate,
            commonTableList.EndSecurityDate,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 320,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { hazardousLargeScaleProjectUuid } = record
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="TwoTwo"
                            title="附件管理"
                            twoTitle="危大工程附件信息"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'AttachmentDetails',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <OpenExcelButton
                            key="two"
                            title="查看明细"
                            OptionsEvent={OptionsEvent}
                            data={{
                                save: true,
                                submit: true,
                                url: 'getHazardousLargeScaleProjectExcel',
                                pos: 'posHazardousLargeScaleProjectExcel',
                                HazardousLargeScaleProjectUuid: hazardousLargeScaleProjectUuid,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
